
(function($){	
	$.fn.iocPlay = function(options){		
		if( typeof options == "string" ){
			var vm = _get_(this[0]);
			if(vm){
				vm.change(options);
			}			
			return this;
		}
		
		options = $.extend({
			speed: 200,
			onchange: function(){				
			}
		}, options);
		
		return this.each(function(){			
				_get_(this, options);	
		});
		
		function _get_(ele, options){
			var vm = $(ele).data("iocPlay");
			if( ! vm && options){
				vm = new _iocPlay_(ele, options);
				$(ele).data("iocPlay", vm);
			}
			return vm;
		}
	};
	
	function _iocPlay_(ele, options){
		this.$this = $(ele);
		this.options = options;
		this._init_();
	}
	
	_iocPlay_.prototype = {
		_init_: function(){
			var $this = this.$this;
			var options = this.options;
			this.$icoDiv = $this.find(".item-image");
			this.$icoPlay = $this.find(".ico-play");
			var self = this;			
			
			this.$icoDiv.hover(
					  function () {
						  self.$icoPlay.fadeIn("slow");
					  },
					  function () {
						  self.$icoPlay.fadeOut('slow');
					  }
			);
			
	
			$("body").click(function(event){
				if(event.target != self.$value[0] && event.target != self.$autobg[0] && event.target != self.$atuoleft[0]){
					self.$wrap.slideUp(options.speed);
				}				
			});		
			
		}, 
		
	};
})(jQuery);